/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package it.unibo.as.db;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Johnny
 */
@Entity
@Table(name = "\"USER\"")
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findByFname", query = "SELECT u FROM User u WHERE u.fname = :fname"),
    @NamedQuery(name = "User.findByLname", query = "SELECT u FROM User u WHERE u.lname = :lname"),
    @NamedQuery(name = "User.findByNickname", query = "SELECT u FROM User u WHERE u.nickname = :nickname"),
    @NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"),
    @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
    @NamedQuery(name = "User.findByPoints", query = "SELECT u FROM User u WHERE u.points = :points"),
    @NamedQuery(name = "User.findByLastlog", query = "SELECT u FROM User u WHERE u.lastlog = :lastlog")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "FNAME", nullable = false, length = 20)
    private String fname;
    @Basic(optional = false)
    @Column(name = "LNAME", nullable = false, length = 20)
    private String lname;
    @Id
    @Basic(optional = false)
    @Column(name = "NICKNAME", nullable = false, length = 20)
    private String nickname;
    @Basic(optional = false)
    @Column(name = "EMAIL", nullable = false, length = 30)
    private String email;
    @Basic(optional = false)
    @Column(name = "PASSWORD", nullable = false, length = 60)
    private String password;
    @Basic(optional = false)
    @Column(name = "POINTS", nullable = false)
    private int points;
    @Basic(optional = false)
    @Column(name = "LASTLOG", nullable = false, insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastlog;

    public User() {
    }

    public User(String nickname) {
        this.nickname = nickname;
    }

    public User(String nickname, String fname, String lname, String email, String password, int points, Date lastlog) {
        this.nickname = nickname;
        this.fname = fname;
        this.lname = lname;
        this.email = email;
        this.password = password;
        this.points = points;
        this.lastlog = lastlog;
    }

    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public String getLname() {
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public Date getLastlog() {
        return lastlog;
    }

    public void setLastlog(Date lastlog) {
        this.lastlog = lastlog;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nickname != null ? nickname.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.nickname == null && other.nickname != null) || (this.nickname != null && !this.nickname.equals(other.nickname))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.unibo.as.db.User[nickname=" + nickname + "]";
    }

}
